﻿using System;
using System.Collections.ObjectModel;

using Sunyi.Project.WebPoint.DataContract;
using Sunyi.Project.WebPoint.ServiceContract;

namespace Sunyi.Project.WebPoint.ServiceAccess
{
    public class UserServiceProxy : WebPointServiceProxy<IUserService>, IUserService
    {
        protected override string ClientEndPointName
        {
            get
            {
                return "UserService";
            }
        }

        public User GetUser(string userName)
        {
            User result = null;
            var channel = this.CreateChannel();

            var action = new Action(delegate { result = channel.GetUser(userName); });

            this.Invoke(channel, action);
            return result;
        }

        public void UpdateUser(User user, Collection<Guid> removedRoles)
        {
            var channel = this.CreateChannel();

            var action = new Action(delegate { channel.UpdateUser(user, removedRoles); });

            this.Invoke(channel, action);
        }
    }
}
